//
//  ShamDetialCell.m
//  YiXiu
//
//  Created by yixiu on 16/8/2.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "ShamDetialCell.h"

@interface ShamDetialCell()

// 图片
@property(nonatomic,strong)UIImageView * pt_url;
//@property(nonatomic,strong)NSString * p_id;

// 时间
@property(nonatomic,strong)UILabel * p_date;

// 内容
@property(nonatomic,strong)UILabel * pt_fragment;
//@property(nonatomic,strong)NSString * s_commentNum;

// 标题
@property(nonatomic,strong)UILabel * p_headline;

@end


@implementation ShamDetialCell


- (instancetype) init{
    
    if (self = [super init]) {
        
        
        [self addSubViews];
        
        
    }
    return self;
}


- (void)addSubViews{
    
    UILabel * titleL = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, KScreenWidth - 20, 40)];
//    titleL.backgroundColor = [UIColor greenColor];
    [self addSubview:titleL];
    titleL.font = [UIFont systemFontOfSize:24];
    
    
    UILabel * dateL = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, KScreenWidth - 20, 30)];
//    dateL.backgroundColor = [UIColor blueColor];
    [self addSubview:dateL];
    dateL.font = [UIFont systemFontOfSize:18];
    
    
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 90, KScreenWidth - 20, 200)];
    imageV.contentMode = UIViewContentModeScaleAspectFill;
//    imageV.backgroundColor = [UIColor yellowColor];
    [self addSubview:imageV];
    
    UILabel * contentL = [[UILabel alloc] initWithFrame:CGRectMake(0, 300, KScreenWidth, 100)];
    contentL.numberOfLines = 0;
//    contentL.backgroundColor = [UIColor greenColor];
    [self addSubview:contentL];
    contentL.font = [UIFont systemFontOfSize:14];
    
    self.p_headline = titleL;
    self.p_date = dateL;
    self.pt_url = imageV;
    self.pt_fragment = contentL;
}



- (void)setModel:(ShaDetailSizeModel *)model{
    _model = model;
    
    self.p_headline.text = model.model.p_headline;
    self.p_date.text = model.model.p_date;
    self.pt_fragment.text = model.model.pt_fragment;
    
    
    [self.pt_url.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    if (model.imageS.count == 1) {
        
        [self.pt_url sd_setImageWithURL:[NSURL URLWithString:model.model.pt_url]];
    
    }else{
        
        [model.imageS enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            UIImageView * imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 200 * idx, KScreenWidth - 20, 190)];
            imageV.contentMode = UIViewContentModeScaleAspectFill;
            imageV.clipsToBounds = YES;
            [imageV sd_setImageWithURL:[NSURL URLWithString:obj]];
            [self.pt_url addSubview:imageV];
            
        }];
    }
    
    self.pt_url.frame = model.pt_url;
    self.pt_fragment.frame = model.pt_fragment;
    
    
}








@end
